import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int q = in.nextInt();
        long[] arr = new long[n + 1];
        arr[0] = 0;
        for (int i = 1; i <= n; i++) {
            arr[i] = in.nextInt();
        }
        //前缀和数组
        long[] dp = new long[n + 1];
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }
        //q次查询
        for (int i = 0; i < q; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
        }
    }
}